<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据集上传</title>
    <link rel="stylesheet" href="./static/dataset-upload.css" />
    <script src="jquery.min.js"></script>
</head>
<body>
  <div class="box">
    <form id="upload-file-form">
        <div style="margin-left: 10px;">
            <label class="upload-input-label">数据上传: </label>
            <input type="file" name="dataset-file"/>
            <input id="upload-submit" type="button" value="提交" onclick="formButton()" />
            <input id="upload-reset" type="button" value="刷新" onclick="resetButton()" />
        </div>
        <div style="margin-left: 10px; margin-top: 40px; display: flex;align-items: center;">
            <label class="upload-res-label">添加结果:</label>
            <textarea class="upload-res" readonly="readonly"></textarea>
        </div>
    </form>
  </div>
</body>
<script type="text/javascript">
    function formButton () {
        var formData = new FormData($("#upload-file-form")[0])

        $.ajax({
            url: "http://127.0.0.1:18160/glm/upload-file?api_key=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",
            type: "post",
            data: formData,
            processData: false,
            contentType: false,
            success: function (res) {
                $(".upload-res").val(JSON.stringify(res, null, "\t"));
            },
            error: function (e) {

            },
        })
    }

    function resetButton() {
        window.location.reload();
    }
</script>
</html>